const express = require("express");
// 1- 下载中间件模块
// cnpm install cookie-parser
// 2- 引入
const cookieParser = require("cookie-parser");
const app = express();
// 3- 使用
app.use(cookieParser());
app.use(express.static(__dirname));
app.get("/setCookie",(req,res)=>{
	// 名字为username,值为zhangsan
	res.cookie("username","zhangsan");
	res.cookie("age","12",{
		maxAge:60*1000,// 单位为毫秒
		path:"/abc"
	});
	res.send("设置cookie");
})
app.get("/getCookie",(req,res)=>{
	console.log(req.headers.cookie)
	console.log(req.cookies)
	res.send("获取cookie");
})
app.get("/delCookie",(req,res)=>{
	res.clearCookie("username");
	res.send("删除cookie");
})
app.listen(80,()=>{
	console.log("success");
})